import 'package:dio/dio.dart';
import 'dart:io';

// import 'dart:convert';
String baseUrl = 'http://192.168.0.102:3000';
var dio = Dio();
getHttp(String url) async {
  String complateUrl = baseUrl + url;
  Options options =
      Options(headers: {HttpHeaders.acceptHeader: "accept: application/json"});
  try {
    var res = await dio.get(complateUrl, options: options);
    if (res.data['code'] == 200) {
      return res.data;
    } else if (res.data['code'] == 301) {
      return {"msg": "需要登录", "code": 301};
    } else {
      return "未知错误";
    }
  } catch (err) {
    print(err);
    return err;
  }
}
